<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!--返回错误信息-->
<?php echo validation_errors(); ?>
<!DOCTYPE html>
<html lang="en">

<head>
    <?php

//        print_r($list);
//        die();
    $title = [
        'title' => '编辑进货单',
    ];
    $this->load->view('/admin/common/header', $title);
    ?>
</head>

<body data-type="widgets">
<script src="/assets/js/theme.js"></script>
<div class="am-g tpl-g">

    <!--    头部   侧边菜单-->
    <?php $this->load->view('/admin/common/bodyLeft'); ?>
    <script type="text/javascript">
    	$(".js-sidebar-nav>li:nth-child(7)>ul").show(80);
    	$(".js-sidebar-nav>li:nth-child(7)>a>span").addClass("sidebar-nav-sub-ico-rotate");
    	$(".js-sidebar-nav>li:nth-child(7)>ul>li:nth-child(3)>a").addClass("active");
    </script>
    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title  am-cf">
                                <ol class="am-breadcrumb am-breadcrumb-slash">
                                    <li><a href="/admin/procurement/index?page=1">采购管理</a></li>
                                    <li><a href='/admin/procurement/purchaseOrder?page=1&needCode=<?php echo $list['needCode'] ?>'>采购进货单</a></li>
                                    <li class="am-active">编辑进货单</li>
                                </ol>
                            </div>
                        </div>
                        <form method="post" enctype="multipart/form-data" class="am-form am-text-sm" id="submitForm">
                            <input type="hidden" name="type" value="采购需求单">
                            <div class="widget-body  am-fr append">
                                <div class="tpl-table-black-operation">
                                    <a href="javascript:void(0);" class="tpl-table-black-operation-del">
                                        基本信息
                                    </a>
                                </div>

                                <div style="margin-top: 20px">
                                    <div class="am-g">
                                        <!-- Row start -->
                                        <div class="am-u-sm-12">
                                                <div class="am-u-md-6">
                                                    <!--<form class="am-form am-text-sm">-->
                                                    <div class="am-form-group am-u-md-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0 must"
                                                                   for="purchaseCode">进货单编号：</label>
                                                            <div class="am-u-md-10">
                                                                <input type="text" name="purchaseCode" value="<?php echo $list['purchaseCode'] ?>"
                                                                   id="purchaseCode" readonly>
                                                            </div>
                                                            
                                                    </div>

                                                    <div class="am-form-group am-u-md-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0 must"
                                                                   for="name">进货单名称：</label>
                                                            <div class="am-u-md-10">
                                                                <input type="text" name="name" value="<?php echo $list['name'] ?>"
                                                                   id="name">
                                                            </div>

                                                            
                                                    </div>

                                                    <div class="am-form-group am-u-md-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0 must"
                                                                   for="documentTime">单据时间</label>
                                                           <!--  <input class="am-u-md-10 form-control" name="documentTime" value="<?php echo date('Y-m-d',$list['documentTime']) ?>"
                                                                   id="documentTime"> -->
                                                            <div class="am-u-md-10">
                                                                <input type="text" class=" am-form-field" placeholder="选择单据时间" data-am-datepicker readonly  name="documentTime" id="documentTime" value="<?php echo date('Y-m-d',$list['documentTime']) ?>"/>
                                                           </div>
                                                    </div>

                                                    <div class="am-form-group am-u-md-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0 must"
                                                                   for="source">所属项目</label>
                                                            <div class="am-u-md-10">
                                                                <?php
                                                                if($list['status'] !=0 ){
                                                                    echo '<input  type="text" name="source" value='.$list['source'].' readonly>';
                                                                }else{
                                                                    echo '<select class="form-control" name="source" id="source" data-am-selected="{btnWidth: \'100%\',maxHeight: 200}">

                                                                    ';
                                                                    foreach ($project as $k=>$v){
                                                                        if($v['name'] == $list['source']){
                                                                        echo '<option value="'.$v['name'].'" selected>'.$v['name'].'</option>';

                                                                    }else{
                                                                        echo '<option value="'.$v['name'].'">'.$v['name'].'</option>';

                                                                    }
                                                                    }
                                                                    echo '</select>';
                                                                }
                                                                ?>
                                                            </div>

                                                            
                                                    </div>

                                                    <div class="am-form-group am-u-md-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0 must"
                                                                   for="content">申请原因</label>
                                                            <div class="am-u-md-10">
                                                                <textarea rows="5" name="content"
                                                                      id="content"><?php echo $list['content'] ?>
                                                            </textarea>
                                                            </div>

                                                            
                                                    </div>
                                                    <!--                                                    </form>-->
                                                </div>

                                                <div class="am-u-md-6">
                                                    <!--                                                    <form class="am-form am-text-sm">-->
                                                    <?php
                                                        if($list['needCode']){
                                                            echo '<div class="am-form-group am-u-md-12">
                                                                <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                       for="needCode">关联需求单：</label>
                                                                <div class="am-u-md-10">
                                                                    <input type="text" name="needCode" value="'.$list['needCode'].'"  id="needCode" readonly>
                                                                </div>
                                                        </div>';
                                                        }else{
                                                            
                                                        }
                                                    ?>

                                                    <div class="am-form-group am-u-md-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0 must"
                                                                   for="supplier">供应商：</label>
                                                            <div class="am-u-md-10">
                                                                <!-- <input type="text" name="supplier" value="<?php echo $list['supplier'] ?>"
                                                                   id="supplier"> -->
<!--                                                                <select class="form-control" name="supplier" id="supplier" data-am-selected="{btnWidth: '100%',maxHeight: 200}">-->
<!--                                                                    <option value=""></option>-->
<!--                                                                </select>-->

                                                                <?php
                                                                if($list['status'] !=0 ){
                                                                    echo '<input  type="text" name="supplier" value='.$list['supplier'].' readonly>';
//                                                                    echo 123123;
                                                                }else{
                                                                    echo '<select class="form-control" name="supplier" id="supplier" data-am-selected="{btnWidth: \'100%\',maxHeight: 200}">';
                                                                    foreach ($supplier as $v2){
                                                                        if($v2['name'] == $list['supplier']){
                                                                            echo '<option value="'.$v2['name'].'" selected>'.$v2['name'].'</option>';

                                                                        }else{
                                                                            echo '<option value="'.$v2['name'].'">'.$v2['name'].'</option>';

                                                                        }
                                                                    }
                                                                    echo '</select>';
                                                                }
                                                                ?>
                                                            </div>

                                                            
                                                    </div>

                                                    <div class="am-form-group am-u-md-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                   for="expectEndTime">期望到货时间</label>
                                                            <!-- <input class="am-u-md-10 form-control" name="expectEndTime" value="<?php echo date('Y-m-d',$list['expectEndTime']) ?>"
                                                                   id="expectEndTime"> -->
                                                            <div class="am-u-md-10">
                                                                <input type="text" class=" am-form-field" placeholder="选择期望到货时间" data-am-datepicker  name="expectEndTime" id="expectEndTime" readonly value="<?php echo date('Y-m-d',$list['expectEndTime']) ?>"/>
                                                            </div>
                                                    </div>

                                                    <div class="am-form-group am-u-md-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0 must"
                                                                   for="createMan">制单人：</label>
                                                            <div class="am-u-md-10">
                                                                 <input  type="text"  name="createMan" value="<?php echo $list['createMan'] ?>"
                                                                   id="createMan">
                                                            </div>

                                                           
                                                    </div>

                                                    <!--                                                    </form>-->
                                                </div>
                                        </div>
                                        <!-- Row end -->
                                    </div>
                                    <hr>
                                </div>

                                <div class="tpl-table-black-operation">
                                    <a href="javascript:void(0);" class="tpl-table-black-operation-del">
                                        详细信息
                                    </a>
                                </div>

                                <div style="margin-top: 20px">
                                    <div class="am-u-sm-12">
                                        <table width="100%"
                                               class="am-table am-table-compact am-table-striped tpl-table-black "
                                               id="example-r">
                                            <thead>
                                            <tr>
                                                <th style="width: 5%">序号</th>
                                                <th style="width: 15%">商品编码</th>
                                                <th style="width: 10%">商品名称</th>
                                                <th style="width: 15%">商品规格</th>
                                                <th style="width: 5%">单位</th>
                                                <th style="width: 10%">进货数量</th>
                                                <th style="width: 10%">进货单价(元)</th>
                                                <th style="width: 10%">进货金额(元)</th>
                                                <th style="width: 20%">备注</th>
                                            </tr>
                                            </thead>
                                            <tbody id="goodsMessage">
                                            <?php

                                              foreach ($list['goodsMessage'] as $k=>$v){
                                                        echo '<tr class="line">
                                              
                                                   <td class="order">'.$v['order'].'</td>
                                                <td data-id="'.$v['dataId'].'" class="product_no">'.$v['product_no'].'</td>
                                                <td class="name">'.$v['name'].'</td>
                                                <td class="specification"  data-id="'.$v['stockPriceId'].'">'.html_entity_decode($v['specification']).'</td>
                                                <td class="goodsUnit">'.$v['goodsUnit'].'</td>';

                                                  if($list['status'] != 0 || strstr($v['specification'], '商品规格+')){
                                                            echo '<td>
                                                    <div class="am-form">
                                                        <input type="text" name="" class="am-u-md-12 form-control quantity" value="'.$v['quantity'].'" readonly>
                                                    </div>
                                                </td>
                                                <td >
                                                    <div class="am-form">
                                                        <input type="text" name="" class="am-u-md-12 form-control price" value="'.$v['price'].'" readonly>
                                                    </div>
                                                </td>
                                                <td class="price-all">'.$v['priceAll'].'</td>
                                                <td>
                                                    <div class="am-form">
                                                        <input type="text" name="" class="am-u-md-12 form-control remarks" value="'.$v['remarks'].'" readonly>
                                                    </div>
                                                </td>
                                            </tr>';
                                                        }else{
                                                            echo '          <td>
                                                    <div class="am-form">
                                                        <input type="text" name="" class="am-u-md-12 form-control quantity" value="'.$v['quantity'].'">
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="am-form">
                                                        <input type="text" name="" class="am-u-md-12 form-control price" value="'.$v['price'].'">
                                                    </div>
                                                </td>
                                                <td class="price-all">'.$v['priceAll'].'</td>

                                                <td>
                                                    <div class="am-form">
                                                        <input type="text" name="" class="am-u-md-12 form-control remarks" value="'.$v['remarks'].'">
                                                    </div>
                                                </td>
                                            </tr>';
                                                      }

                                                    }


                                                ?>
                                            <!-- more data -->
                                            </tbody>
                                        </table>
                                        <button type="button" class="am-btn am-btn-secondary"  data-am-modal="{target: '#changeCommodity', closeViaDimmer: 0, width: 900, height: 500}" id="chooseCommodity">选择商品</button>
                                        <div class="am-fr" style="font-size: 16px;line-height: 37px">
                                            共<span id="class"><?php $attribute = explode('/',$list['attribute']);echo $attribute[0].'</span>类,'.'<span id="quantity-all">'.$attribute[1].'</span>件商品';
                                                ?>

                                        </div>
                                        <hr>
                                    </div>
                                </div>

                                <div class="tpl-table-black-operation">
                                    <a href="javascript:void(0);" class="tpl-table-black-operation-del">
                                        合同信息
                                    </a>
                                </div>

                                <div style="margin-top: 20px">
                                    <div class="am-g">
                                        <div class="am-u-sm-12">
                                            <div class="am-g">
                                                <div class="am-u-md-6">
                                                    <div class="am-form-group am-u-sm-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                   for="all-money">采购金额(总计)小写</label>
                                                            <div class="am-u-md-10">
                                                                <input type="text"  name="amountSmall" value="<?php echo $list['contractInfo']['amountSmall'] ?>"
                                                                   id="all-money" readonly>
                                                            </div>

                                                            
                                                    </div>

                                                    <div class="am-form-group am-u-sm-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                   for="deliveryType">交货方式</label>
                                                            <div class="am-u-md-10">
                                                                <input type="text" name="deliveryType" value="<?php echo $list['contractInfo']['deliveryType'] ?>"
                                                                   id="deliveryType">
                                                            </div>

                                                            
                                                    </div>

                                                    <div class="am-form-group am-u-sm-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                   for="freight">运费负担</label>
                                                            <div class="am-u-md-10">
                                                                <input type="text" name="freight" value="<?php echo $list['contractInfo']['freight'] ?>"
                                                                   id="freight">
                                                            </div>

                                                            
                                                    </div>

                                                    <div class="am-form-group am-u-sm-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                   for="jiaohuoTime">交货时间</label>
                                                            <div class="am-u-md-10">
                                                                <input type="text" name="jiaohuoTime" value="<?php echo $list['contractInfo']['jiaohuoTime'] ?>"
                                                                   id="jiaohuoTime">
                                                            </div>

                                                            
                                                    </div>

                                                    <div class="am-form-group am-u-sm-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                   for="payWay">支付方式</label>
                                                            <div class="am-u-md-10">
                                                                <input type="text" name="payWay" value="<?php echo $list['contractInfo']['payWay'] ?>"
                                                                   id="payWay">
                                                            </div>

                                                            
                                                    </div>
                                                    <div class="am-form-group am-u-sm-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                   for="address">收货地址及联系人</label>
                                                           <div class="am-u-sm-10">
                                                               <textarea class="am-u-md-11 form-control" rows="5" name="address"
                                                                      id="address"><?php echo $list['contractInfo']['address'] ?></textarea>
                                                           </div>
                                                            
                                                    </div>

                                                </div>

                                                <div class="am-u-md-6">
                                                    <div class="am-form-group am-u-sm-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                   for="amountBig">采购金额(总计)大写</label>
                                                            <div class="am-u-md-10">
                                                                <input type="text" name="amountBig" value="<?php echo $list['contractInfo']['amountBig'] ?>"
                                                                   id="amountBig" readonly>
                                                            </div>

                                                            
                                                    </div>

                                                    <div class="am-form-group am-u-sm-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                   for="deliveryAddress">交货地点</label>
                                                            <div class="am-u-md-10">
                                                                <input type="text" name="deliveryAddress" value="<?php echo $list['contractInfo']['deliveryAddress'] ?>"
                                                                   id="deliveryAddress">
                                                            </div>

                                                            
                                                    </div>

                                                    <div class="am-form-group am-u-sm-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                   for="logistics">物流保价</label>
                                                            <div class="am-u-md-10">
                                                                <input type="text" name="logistics" value="<?php echo $list['contractInfo']['logistics'] ?>"
                                                                   id="logistics">
                                                            </div>

                                                            
                                                    </div>

                                                    <div class="am-form-group am-u-sm-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                   for="paymentWay">付款方式</label>
                                                            <div class="am-u-md-10">
                                                                <input  type="text"  name="paymentWay" value="<?php echo $list['contractInfo']['paymentWay'] ?>"
                                                                   id="paymentWay">
                                                            </div>

                                                            
                                                    </div>

                                                    <div class="am-form-group am-u-sm-12">
                                                            <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                                   for="invoice">发票交付</label>
                                                            <div class="am-u-md-10">
                                                                <input  type="text"  name="invoice" value="<?php echo $list['contractInfo']['invoice'] ?>"
                                                                   id="invoice">
                                                            </div>

                                                            
                                                    </div>

                                                </div>
                                                <div class="am-u-md-12">
                                                    
                                                    <div class="am-form-group am-g am-u-md-6">
                                                        <div class="am-u-md-12">
                                                            <button class="am-btn  hover-btn" type="button"
                                                                    data-am-popover="{theme: 'warning',content: '免责事项免责事', trigger: 'hover focus'}">
                                                              免责事项:
                                                            </button>（鼠标移动到标签上字段弹窗显示事项内容）
                                                        </div>
                                                        
                                                    </div>
                                                    <div class="am-form-group am-u-md-6">
                                                        <div class="am-u-md-12">
                                                            <button class="am-btn hover-btn" type="button"
                                                                data-am-popover="{theme: 'warning',content: '免责事项免责事', trigger: 'hover focus'}">
                                                                其它事项:
                                                            </button>（鼠标移动到标签上字段弹窗显示事项内容）
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <hr>
                                </div>

                                <div class="tpl-table-black-operation">
                                    <a href="javascript:void(0);" class="tpl-table-black-operation-del">
                                        报价确认单
                                    </a>
                                </div>

                                <div style="margin-top: 20px">
                                    <div class="am-g">
                                        <div class="am-u-sm-12">
                                                <div class="am-u-md-6">
                                                    <div class="am-form-file am-u-sm-12">
                                                        <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                               for="confirmImg">报价确认单：</label>
                                                               
                                                        <?php

                                                            if($list['status'] != 0 && $list['confirmCard']){
                                                                echo '<div class="confirm" style="display:block">
                                                                <a href="'.$list['confirmCard'].'" download="报价确认单">
                                                                    <i class="am-icon-download"></i> 下载报价确认单
                                                                </a>
                                                            <input type="hidden"  name="confirmImg" value="'.$list['confirmCard'].' " >
                                                        </div>';
                                                            }elseif (!$list['confirmCard']){
                                                                echo '<a href="javascript:;">
                                                                <i class="am-icon-times-circle"></i> 未上传
                                                            </a>';
                                                            }
                                                            else{
                                                                echo '
                                                                <div class="am-u-md-10">
                                                                    <button type="button" class="am-btn am-btn-default am-btn-sm">
                                                                        <i class="am-icon-cloud-upload"></i> 选择要上传的文件
                                                                    </button>
                                                                        <input type="file" class="am-u-md-2 form-control" name="confirm" value="" id="confirm">
                                                                    <span class="file-show"></span>
                                                                </div>


                                                                ';
                                                            }

                                                        ?>

                                                    </div>

                                                </div>
                                        </div>
                                    </div>
                                    <hr>
                                </div>

                                <div class="tpl-table-black-operation">
                                    <a href="javascript:void(0);" class="tpl-table-black-operation-del">
                                        付款信息
                                    </a>
                                </div>

                                <div style="margin-top: 20px">
                                    <div class="am-g">
                                        <!-- Row start -->
                                        <div class="am-u-sm-12">
                                            <div class="am-g pay-message" id="pay-message">
                                                <div class="am-u-md-12 ">

                                                    <input type="hidden" name="id" value="<?php echo $list['id'] ?>">
                                                    <input type="hidden" name="status" value="<?php echo $list['status'] ?>">
                                                    <input type="hidden" name="onStatus" value="<?php echo $list['onStatus'] ?>">
                                                    <input type="hidden" name="actionStatus" value="<?php isset($_GET['status']) ? $_GET['status'] : '' ?>">
<!--                                                    todo 判断status是否存在不存在则为1-->
                                                </div>
                                                <!-- <div class="am-u-md-12">
                                                    <div class="am-u-md-4">
                                                            <label class="am-u-md-4 am-md-text-right am-padding-left-0"
                                                                   for="">采购金额预付: </label>
                                                            <input type="text" name="" id="" style="width: 200px">
                                                    </div>
                                                    <div class="am-u-md-2">
                                                        <div class="am-input-group" style="width: 148px;left: -44px;">
                                                              <input type="text" class="am-form-field" style="height: 34px;">
                                                              <span class="am-input-group-label" style="line-height: 31px;height: 34px;">元</span>
                                                            </div>
                                                    </div>
                                                    

                                                    <div class="am-u-md-3" style="left: -50px;">
                                                            <label class="am-u-md-4 am-md-text-right am-padding-left-0"
                                                                   for="" style="width: 70px">付款人员: </label>
                                                            <select data-am-selected="{btnSize: 'sm'}" name="payMan">
                                                                <option value="请选财务人员">请选财务人员</option>
                                                                <option value="王光明">王光明</option>
                                                                <option value="金碧波">金碧波</option>
                                                                <option value="XXXX">XXXX</option>
                                                            </select>
                                                    </div>

                                                    <div class="am-u-md-3" style="left: -50px;">
                                                            <label class="am-u-md-4 am-md-text-right am-padding-left-0"
                                                                   for="">付款确状态: </label>
                                                            <button type="button" class="am-btn am-btn-default">未确认</button>
                                                    </div>
                                                </div> -->
                                            </div>
                                        </div>
                                        <!-- Row end -->
                                    </div>
                                    <hr>
                                </div>
                                <!-- Row end -->
                            </div>
                            <div class="btn-box">
                                <?php
                                if($list['status'] == 1 || $list['status'] == 5){
                                    echo '<button onclick="back()" type="button" class="am-btn am-btn-primary tpl-btn-bg-color-success " style="width:220px;margin: 20px;">取消</button>';
                                }else{
                                    echo '
                                        <input type="submit" value="提交" class="am-btn am-btn-primary tpl-btn-bg-color-success commit " style="width:220px;margin: 20px;">
                                        <button onclick="back()" type="button" class="am-btn am-btn-primary tpl-btn-bg-color-success " style="width:220px">取消</button>
                                        ';
                                }
                                ?>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 模态框 -->
<div class="am-modal am-modal-no-btn" tabindex="-1" id="addSpecification">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">选择规格
            <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
        </div>
        <div class="am-modal-bd">
            <table class="am-table am-table-bordered am-table-radius am-table-striped am-table-hover">
                <thead>
                    <tr>
                        <th style="width: 60%">规格</th>
                        <th style="width: 40%">进货数量</th>
                    </tr>
                </thead>
                <tbody class="specification-box">
                    <!-- <tr>
                        <td class="specification-value">白色</td>
                        <td class="specification-value">XL</td>
                        <td class="specification-value">塑料</td>
                        <td><div class="am-form"><input type="text" name="" class=""></div></td>
                    </tr>
                    <tr>
                        <td class="specification-value">按时</td>
                        <td class="specification-value">X</td>
                        <td class="specification-value">塑料</td>
                        <td><div class="am-form"><input type="text" name="" class=""></div></td>
                    </tr>
                    <tr>
                        <td class="specification-value">白按时色</td>
                        <td class="specification-value">XL</td>
                        <td class="specification-value">塑12料</td>
                        <td><div class="am-form"><input type="text" name="" class=""></div></td>
                    </tr>
                    <tr>
                        <td class="specification-value">白123色</td>
                        <td class="specification-value">XL</td>
                        <td class="specification-value">塑1231料</td>
                        <td><div class="am-form"><input type="text" name="" class=""></div></td>
                    </tr> -->
                </tbody>
            </table>
        </div>
        <div class="btn-box">
            <button type="button" class="am-btn am-btn-primary" id="confirmSpecification" data-am-modal-close>确认</button>
        </div>
    </div>
</div>
<!-- 模态框 -->
<div class="am-modal am-modal-no-btn" tabindex="-1" id="changeCommodity">
  <div class="am-modal-dialog">
    <div class="am-modal-hd">选择商品
      <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
    </div>
    <div class="am-modal-bd">
        <div class="fl">
            <div class="box">
                <div class="list-title">
                    所有分类
                </div>
                <div class="left-list">

                </div>
            </div>
        </div>
        <div class="fr goods-details">
            <form class="am-form am-form-horizontal">
                <div class="am-form-group search-box">
                    <div class="am-u-sm-8 search-input">
                        <input type="text" id="searchValue" placeholder="请输入商品名称查询。">
                    </div>
                    <div class="am-u-sm-2" >
                        <button type="button" class="am-btn am-btn-success" id="searchCommodity">查询</button>
                    </div>
                    <div class="am-u-sm-2">
                        <button type="button" class="am-btn am-btn-primary" id="addCommodity" data-am-modal-close>确认</button>
                    </div>
                </div>
            </form>
            <div class="am-u-sm-12 table-box">
                <table class="am-table am-table-bordered am-table-radius am-table-striped am-table-hover">
                    <thead>
                        <tr>
                            <th style="width: 5%;"><input type="checkbox" class="check-all" name=""></th>
                            <th style="width: 10%;">序号</th>
                            <th style="width: 25%;">商品编号</th>
                            <th style="width: 25%;">商品名称</th>
                            <th style="width: 10%;">单位</th>
                            <th style="width: 15%;">缺货数量</th>
                        </tr>
                    </thead>
                    <tbody class="tr-box">

                    </tbody>
                </table>
            </div>

            <div class="pagination-box">
                <ul class="am-pagination" id="pagination">
                </ul>
            </div>
        </div>
    </div>
  </div>
</div>

<script src="/assets/js/amazeui.min.js"></script>
<script src="/assets/js/amazeui.datatables.min.js"></script>
<script src="/assets/js/dataTables.responsive.min.js"></script>
<script src="/assets/js/app.js"></script>
<script src="/assets/js/zdy_form.js"></script>
<script src="/assets/js/page.js"></script>
<script src="/assets/js/procurement.js"></script>

<script>
    

    var status = GetQueryString('status');
    var thisId = GetQueryString('id');
    var input_status = $("input[name='status']").val();

    // if(input_status != status){
    //     alert("非法操作，即将返回上一级！");
    //     window.history.go(-1);
    // };

    //报告单附件
    var reportCard = "<?php echo $list['reportCard']?>";
    var reportCardDownload = "";
    if(reportCard){
        reportCardDownload += '<a href="<?php echo $list['reportCard']?>" download="生产抽检报告单">'
                                + '<i class="am-icon-download"></i> 下载生产抽检报告单'
                            + '</a>';
    }else{
        reportCardDownload += '<a href="javascript:;">'
                                + '<i class="am-icon-times-circle"></i> 未上传'
                            + '</a>';
    }
    //物流签收单
    var expressCard = "<?php echo @$list['logisticsInfo']['expressCard']?>";
    var expressCardDownload = "";
    if(expressCard){
        expressCardDownload += '<a href="<?php echo @$list['logisticsInfo']['expressCard']?>" download="生产抽检报告单">'
                                + '<i class="am-icon-download"></i> 下载生产抽检报告单'
                            + '</a>';
    }else{
        expressCardDownload += '<a href="javascript:;">'
                                + '<i class="am-icon-times-circle"></i> 未上传'
                            + '</a>';
    }
    //终端验收报告
    var terminalCard = "<?php echo @$list['logisticsInfo']['terminalCard']?>";
    var terminalCardDownload = "";
    if(terminalCard){
        terminalCardDownload += '<a href="<?php echo @$list['logisticsInfo']['terminalCard']?>" download="终端验收报告单">'
                                + '<i class="am-icon-download"></i> 下载终端验收报告单'
                            + '</a>';
    }else{
        terminalCardDownload += '<a href="javascript:;">'
                                + '<i class="am-icon-times-circle"></i> 未上传'
                            + '</a>';
    }
    //验收单附件
    var pledgeGoldCard = "<?php echo @$list['pledgeGoldCard']?>";
    var pledgeGoldCardDownload = "";
    if(pledgeGoldCard){
        pledgeGoldCardDownload += '<a href="<?php echo @$list['pledgeGoldCard']?>" download="终端验收报告单">'
                                + '<i class="am-icon-download"></i> 下载终端验收报告单'
                            + '</a>';
    }else{
        pledgeGoldCardDownload += '<a href="javascript:;">'
                                + '<i class="am-icon-times-circle"></i> 未上传'
                            + '</a>';
    }






    if(status != 0){
        $("input[name='needCode']").attr("readonly","");
        $("input[name='name']").attr("readonly","");
        $("input[name='supplier']").attr("readonly","");
        $("input[name='documentTime']").attr("readonly","");
        $("input[name='expectEndTime']").attr("readonly","");
        $("input[name='source']").attr("readonly","");
        $("input[name='createMan']").attr("readonly","");
        $("textarea[name='content']").attr("readonly","");
        $("input[name='amountSmall']").attr("readonly","");
        $("input[name='amountBig']").attr("readonly","");
        $("input[name='deliveryType']").attr("readonly","");
        $("input[name='deliveryAddress']").attr("readonly","");
        $("input[name='logistics']").attr("readonly","");
        $("input[name='jiaohuoTime']").attr("readonly","");
        $("input[name='freight']").attr("readonly","");
        $("input[name='paymentWay']").attr("readonly","");
        $("input[name='payWay']").attr("readonly","");
        $("input[name='invoice']").attr("readonly","");
        $("textarea[name='address']").attr("readonly","");
        // $("input[name='confirm']").remove();
        // $("div[class='confirm']").css("display","block");

        $(".specification-btn").attr("disabled","disabled");
        $("button[id='chooseCommodity']").attr("disabled","disabled");
        $(".remarks").attr("disabled","disabled");
        $(".price").attr("disabled","disabled");
        $(".quantity").attr("disabled","disabled");

        // $("select[name='prepay']").attr("disabled","false");
        // $("select[name='payMan']").attr("disabled","false");
        var lockSubmit =false;
        $(".commit").bind("click",function(e){
            e.preventDefault();
            if(lockSubmit){
                return false;
            }
            lockSubmit =true;
            var formData = new FormData($("#submitForm")[0]);
            var action = $(this).val();
            var attribute = $("#class").text() + "/" + $("#quantity-all").text();
            var goodsMessage = getGoodsMessage();

            formData.append("attribute",attribute);
            formData.append("action",action);
            formData.append("amount",getAllPrice());
            formData.append("goodsMessage",goodsMessage);
            $.ajax({
                type: "POST",
                url : '/admin/procurement/purchaseOrderEdit',
                data: formData,
                cache: false,
                processData: false,
                contentType: false,
                success: function(data){
                    window.location.href = '/admin/procurement/purchaseOrder?page=1';
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                },
            });
            return false;
        });


    }

    if(status == 0){
        $(".pay-message").append('<div class="am-u-md-12">'+
            '<div class="am-g">'+
            '<div class="am-u-md-3">'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="payProportion">采购金额预付款</label>'+
            '<div class="am-u-md-8">'+
            '<select id="payProportion" name="payInfo[0][prepay]" class="prepay">'+
            '<option value="0">请选择付款比例</option>'+
            '<option value="0.05">预付款5%</option>'+
            '<option value="0.1">预付款10%</option>'+
            '<option value="0.15">预付款15%</option>'+
            '<option value="0.2">预付款20%</option>'+
            '<option value="0.3">预付款30%</option>'+
            '<option value="0.4">预付款40%</option>'+
            '<option value="0.5">预付款50%</option>'+
            '<option value="0.6">预付款60%</option>'+
            '<option value="0.7">预付款70%</option>'+
            '<option value="0.8">预付款80%</option>'+
            '<option value="1">预付款100%</option>'+
            '</select></div></div>'+
            '<div class="am-input-group am-u-md-3">'+
            '<input type="text" class="am-form-field amount" id="pay-money" name="payInfo[0][amount]" readonly>'+
            '<span class="am-input-group-label">元</span>'+
            '</div>'+
            '<div class="am-u-md-3">'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="payMan" >付款人员:</label>'+
            '<div class="am-u-md-8">'+
            '<select name="payInfo[0][payMan]" class="payMan" id="payMan">'+
            '<option value="">请选财务人员</option>'+
            '</select></div></div>'+
            '<div class="am-u-md-3">'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态:</label>'+
            '<button type="button" class="am-btn am-btn-default">未确认</button></div></div></div>');

        addAudit("/admin/user/ccLevel","#payMan");//添加审批抄送人

        addMessage(thisId);

          // 添加审批人员
        function addMessage(id){
            $.ajax({
                url:"/admin/procurement/editCCList",
                data:{
                    id: id
                },
                dataType:"json",
                type:"post",
                success:function(data){
                    console.log(data)
                    var prepay = data.prepay;
                    var amount = data.amount;
                    var payMan = data.payMan;

                    $("#payProportion option").each(function (){
                        if($(this).val()==prepay){
                            $(this).attr("selected",true);
                        }
                    });
                    $("#payMan option").each(function (){
                        if($(this).text()==payMan){
                            $(this).attr("selected",true);
                        }
                    });

                    $("#pay-money").val(amount);
                }
            });
        }

        $("#confirm").change(function (event) {

            var filePath = $(this).val();
            if(filePath){
                var arr = filePath.split('\\');
                var fileName = arr[arr.length-1];
                $(".file-show").html(fileName);
            }else{
                $(".file-show").html("");
                return false;
            }
            
        });

        var lockSubmit = false;
        $(".commit").bind("click",function(e){
            e.preventDefault();
            if(lockSubmit){
                return false;
            }
            lockSubmit =true;
            // 表单验证
            var valid = zdy.validate.valid({
                rules:{
                    supplier:{required:true},
                    name:{required:true},
                    documentTime:{required:true},
                    createMan:{required:true},
                    source:{required:true},
                    content:{required:true}
                }, message:{
                    supplier:{required:"请填写供应商"},
                    name:{required:"请填写进货单名称"},
                    documentTime:{required:"请填写单据时间"},
                    createMan:{required:"请填写制单人"},
                    source:{required:"请选择所属项目"},
                    content:{required:"请输入申请原因"}

                }
            });
            if (!valid) {
                lockSubmit = false;
                return;
            }

            var formData = new FormData($("#submitForm")[0]);
            var action = $(this).val();
            var attribute = $("#class").text() + "/" + $("#quantity-all").text();
            var goodsMessage = getGoodsMessage();
            var endTime  = $("#endTime").val();

            if (!endTime) {
                formData.delete("endTime");
                formData.append("endTime","未填写期望到货时间");
            }
            if(goodsMessage.length <= 2){
                $("#pop-up-content").text("请选择商品");
                $("#my-alert").modal();
                lockSubmit = false;
                return;
            }

            formData.append("attribute",attribute);
            formData.append("action",action);
            formData.append("amount",getAllPrice());
            formData.append("goodsMessage",goodsMessage);
            $.ajax({
                type: "POST",
                url : '/admin/procurement/purchaseOrderEdit',
                data: formData,
                cache: false,
                processData: false,
                contentType: false,
                success: function(data){
                    window.location.href = '/admin/procurement/purchaseOrder?page=1';
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                },
            });
            return false;
        });

        

    }else if(status == 1){

        $(".pay-message").append('<div class="am-u-md-12">'+
        '<div class="am-u-md-3">'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额预付款: </label>'+
            '<div class="am-u-md-8">'+
                '<input type="text" name="payInfo[0][prepay]"  readonly value="<?php echo @$list['payInfo'][0]['prepay'] ?>">'+
            '</div>'+
        '</div>'+
        '<div class="am-u-md-3">'+
            '<div class="am-input-group am-u-md-12">'+
                '<input type="text" class="am-form-field" name="payInfo[0][amount]" value="<?php echo @$list['payInfo'][0]['amount'] ?>" readonly >'+
                '<span class="am-input-group-label" >元</span>'+
            '</div>'+
        '</div>'+
        '<div class="am-u-md-3" >'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
            '<div class="am-u-md-8" >'+
            '<input type="text" name="payInfo[0][payMan]" value="<?php echo @$list['payInfo'][0]['payMan'] ?>" readonly>'+
        '</div>'+
        '</div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
        '<button type="button" class="am-btn am-btn-default">未确认</button></div></div>');


    }else if(status == 2){
        $(".pay-message").append('<div class="am-u-md-12 am-form-group">'+
            '<div class="am-u-md-3">'+
                '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额预付款: </label>'+
                '<div class="am-u-md-8">'+
                    '<input type="text" name="payInfo[0][prepay]"  readonly value="<?php echo @$list['payInfo'][0]['prepay'] ?>">'+
                '</div>'+
            '</div>'+
            '<div class="am-u-md-3">'+
                '<div class="am-input-group am-u-md-12">'+
                    '<input type="text" class="am-form-field" name="payInfo[0][amount]" value="<?php echo @$list['payInfo'][0]['amount'] ?>" readonly >'+
                    '<span class="am-input-group-label" >元</span>'+
                '</div>'+
            '</div>'+
            '<div class="am-u-md-3" >'+
                '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
                '<div class="am-u-md-8" >'+
                '<input type="text" name="payInfo[0][payMan]" value="<?php echo @$list['payInfo'][0]['payMan'] ?>" readonly>'+
            '</div>'+
            '</div>'+
            '<div class="am-u-md-3">'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
            '<button type="button" class="am-btn am-btn-default">已确认</button></div></div>'+

            '<div class="am-u-md-12 am-form-group">'+
            '<div class="am-u-md-3">'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额进度款: </label>'+
            '<div class="am-u-md-8">'+
            '<select data-am-selected="{btnWidth: \'100%\',maxHeight: 100}" id="payProportion" name="payInfo[1][prepay]">'+
            '<option value="0">请选择付款比例</option>'+
            '<option value="0.05">预付款5%</option>'+
            '<option value="0.1">预付款10%</option>'+
            '<option value="0.15">预付款15%</option>'+
            '<option value="0.2">预付款20%</option>'+
            '<option value="0.3">预付款30%</option>'+
            '<option value="0.4">预付款40%</option>'+
            '<option value="0.5">预付款50%</option>'+
            '<option value="0.6">预付款60%</option>'+
            '<option value="0.7">预付款70%</option>'+
            '<option value="0.8">预付款80%</option>'+
            '<option value="1">预付款100%</option>'+
            '</select></div></div>'+
            '<div class="am-u-md-3">'+
            '<div class="am-input-group am-u-md-12">'+
            '<input type="text" class="am-form-field" id="pay-money" name="payInfo[1][amount]" readonly>'+
            '<span class="am-input-group-label">元</span>'+
            '</div></div>'+
            '<div class="am-u-md-3">'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
            '<div class="am-u-md-8">'+
            '<select data-am-selected="{btnWidth: \'100%\',maxHeight: 100}" name="payInfo[1][payMan]" id="payMan">'+
            '<option value="">请选财务人员</option>'+
            '</select></div></div>'+
            '<div class="am-u-md-3">'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
            '<button type="button" class="am-btn am-btn-default">未确认</button></div></div>');


        $(".append").append('<div class="tpl-table-black-operation">'+
        '<a href="javascript:void(0);" class="tpl-table-black-operation-del">'+
        ' 出产抽检报告单'+
        '</a>'+
        '</div>'+
        '<div style="margin-top: 20px">'+
        '<div class="am-u-sm-12">'+
        '<div class="am-u-md-6">'+
        '<div class="am-form-file am-u-md-12">'+
            '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">报告单附件：</label>'+
            '<div class="am-u-md-10">'+
                '<button type="button" class="am-btn am-btn-default am-btn-sm">'+
                    '<i class="am-icon-cloud-upload"></i> 选择要上传的文件'+
                '</button>'+
                '<input type="file" class="am-u-md-10 form-control" name="reportCard" id="reportCard">'+
                '<span class="file-show2"></span>'+
                '<input type="hidden" name="actionStatus" value="'+status+'">'+
            '</div>'+
        '</div>'+
        '<span class="am-u-md-10">建议1080*720px</span>'+
        '</div>'+
        '</div>'+
        ' <hr>'+
        '</div>'
        );

        $("#reportCard").change(function (event) {

            var filePath = $(this).val();
            if(filePath){
                var arr = filePath.split('\\');
                var fileName = arr[arr.length-1];
                $(".file-show2").html(fileName);
            }else{
                $(".file-show2").html("");
                return false;
            }
            
        });

        addAudit("/admin/user/ccLevel","#payMan");//添加审批抄送人

    }else if(status == 3){

        $(".pay-message").append('<div class="am-u-md-12 am-form-group">'+
        '<div class="am-u-md-3">'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额预付款: </label>'+
            '<div class="am-u-md-8">'+
                '<input type="text" name="payInfo[0][prepay]"  readonly value="<?php echo @$list['payInfo'][0]['prepay'] ?>">'+
            '</div>'+
        '</div>'+
        '<div class="am-u-md-3">'+
            '<div class="am-input-group am-u-md-12">'+
                '<input type="text" class="am-form-field" name="payInfo[0][amount]" value="<?php echo @$list['payInfo'][0]['amount'] ?>" readonly >'+
                '<span class="am-input-group-label" >元</span>'+
            '</div>'+
        '</div>'+
        '<div class="am-u-md-3" >'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
            '<div class="am-u-md-8" >'+
            '<input type="text" name="payInfo[0][payMan]" value="<?php echo @$list['payInfo'][0]['payMan'] ?>" readonly>'+
        '</div>'+
        '</div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
        '<button type="button" class="am-btn am-btn-default">已确认</button></div></div>'+

        '<div class="am-u-md-12 am-form-group">'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额进度款: </label>'+
        '<div class="am-u-md-8">'+
        '<input type="text" name="payInfo[1][prepay]" id="" value="<?php echo @$list['payInfo'][1]['prepay'] ?>" readonly >'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<div class="am-input-group am-u-md-12">'+
        '<input type="text" class="am-form-field" readonly name="payInfo[1][amount]" value="<?php echo @$list['payInfo'][1]['amount'] ?>">'+
        '<span class="am-input-group-label">元</span>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
        '<div class="am-u-md-8">'+
        '<input type="text" name="payInfo[1][payMan]"  id="" value="<?php echo @$list['payInfo'][1]['payMan'] ?>" readonly>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
        '<button type="button" class="am-btn am-btn-default">已确认</button></div></div>'+

        '<div class="am-u-md-12 am-form-group" >'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额尾款: </label>'+
        '<div class="am-u-md-8">'+
        '<select data-am-selected="{btnWidth: \'100%\',maxHeight: 100}" id="payProportion" name="payInfo[2][prepay]">'+
        '<option value="0">请选择付款比例</option>'+
        '<option value="0.05">预付款5%</option>'+
        '<option value="0.1">预付款10%</option>'+
        '<option value="0.15">预付款15%</option>'+
        '<option value="0.2">预付款20%</option>'+
        '<option value="0.3">预付款30%</option>'+
        '<option value="0.4">预付款40%</option>'+
        '<option value="0.5">预付款50%</option>'+
        '<option value="0.6">预付款60%</option>'+
        '<option value="0.7">预付款70%</option>'+
        '<option value="0.8">预付款80%</option>'+
        '<option value="1">预付款100%</option>'+
        '</select></div></div>'+
        '<div class="am-u-md-3">'+
        '<div class="am-input-group am-u-md-12">'+
        '<input type="text" class="am-form-field" id="pay-money" name="payInfo[2][amount]" readonly>'+
        '<span class="am-input-group-label">元</span>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
        '<div class="am-u-md-8">'+

        '<select data-am-selected="{btnWidth: \'100%\',maxHeight: 100}" name="payInfo[2][payMan]" id="payMan">'+
        '<option value="">请选财务人员</option>'+
        '</select></div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
        '<button type="button" class="am-btn am-btn-default">未确认</button></div></div>');



        $(".append").append(
        '<div class="tpl-table-black-operation">'+
        '<a href="javascript:void(0);" class="tpl-table-black-operation-del">'+
        '出产抽检报告单'+
        '</a>'+
        '</div>'+
        '<div class="am-u-sm-12">'+
        '<div class="am-g">'+
        '<div class="am-u-sm-12">'+
        '<div class="am-g">'+
        '<div class="am-u-md-6">'+
        '<div class="am-form-group">'+
        '<div class="am-g">'+
        '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">报告单附件：</label>'+
        reportCardDownload+
        ' </div>'+
        '</div>'+
        '</div>'+
        '</div>'+
        '</div>'+
        '</div>'+
        ' <hr>'+
        '</div>'+
        '<div class="tpl-table-black-operation">'+
        '<a href="javascript:void(0);" class="tpl-table-black-operation-del">'+
        '物流信息验收</a>'+
        '</div>'+
        '<div class="am-u-sm-12">'+
        '<div class="am-g">'+
        '<div class="am-u-sm-12">'+
        '<div class="am-g">'+
        '<div class="am-u-md-6">'+
            '<div class="am-form-group am-u-sm-12">'+
                '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">物流公司：</label>'+
                '<div class="am-u-md-10">'+
                    '<input type="text" name="express" value="" id="" >'+
                '</div>'+
            '</div>'+
            '<div class="am-form-file am-u-sm-12">'+
                '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="expressCard">物流签收单：</label>'+
                '<div class="am-u-md-10">'+
                    '<button type="button" class="am-btn am-btn-default am-btn-sm">'+
                        '<i class="am-icon-cloud-upload"></i> 选择要上传的文件'+
                    '</button>'+
                    '<input type="file" class="am-u-md-10 form-control" name="expressCard" id="expressCard">'+
                    '<span class="file-show3"></span>'+
                '</div>'+
            '</div>'+
            '<span class="am-u-md-10 ">建议1080*720px</span>'+

        ' </div>'+
        '<div class="am-u-md-6">'+
            '<div class="am-form-group am-u-sm-12">'+
                '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">快递单号：</label>'+
                '<div class="am-u-md-10">'+
                    '<input type="text" name="courierNumber" value="" id="" >'+
                '</div>'+
            '</div>'+
            '<div class="am-form-file am-u-sm-12">'+
                '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="terminalCard">终端验收报告：</label>'+
                '<div class="am-u-md-10">'+
                    '<button type="button" class="am-btn am-btn-default am-btn-sm">'+
                        '<i class="am-icon-cloud-upload"></i> 选择要上传的文件'+
                    '</button>'+
                    '<input type="file" class="am-u-md-10 form-control" name="terminalCard" id="terminalCard">'+
                    '<span class="file-show4"></span>'+
                '</div>'+
                '<input type="hidden" name="actionStatus" value="'+status+'">'+
            '</div>'+
            '<span class="am-u-md-10 ">建议1080*720px</span>'+

        '</div></div></div></div></div>'
        );

        addAudit("/admin/user/ccLevel","#payMan");//添加审批抄送人

        $("#expressCard").change(function (event) {

            var filePath = $(this).val();
            if(filePath){
                var arr = filePath.split('\\');
                var fileName = arr[arr.length-1];
                $(".file-show3").html(fileName);
            }else{
                $(".file-show3").html("");
                return false;
            }
            
        });

        $("#terminalCard").change(function (event) {

            var filePath = $(this).val();
            if(filePath){
                var arr = filePath.split('\\');
                var fileName = arr[arr.length-1];
                $(".file-show4").html(fileName);
            }else{
                $(".file-show4").html("");
                return false;
            }
            
        });


    }else if(status == 4){

        $(".pay-message").append('<div class="am-u-md-12 am-form-group">'+
        '<div class="am-u-md-3">'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额预付款: </label>'+
            '<div class="am-u-md-8">'+
                '<input type="text" name="payInfo[0][prepay]"  readonly value="<?php echo @$list['payInfo'][0]['prepay'] ?>">'+
            '</div>'+
        '</div>'+
        '<div class="am-u-md-3">'+
            '<div class="am-input-group am-u-md-12">'+
                '<input type="text" class="am-form-field" name="payInfo[0][amount]" value="<?php echo @$list['payInfo'][0]['amount'] ?>" readonly >'+
                '<span class="am-input-group-label" >元</span>'+
            '</div>'+
        '</div>'+
        '<div class="am-u-md-3" >'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
            '<div class="am-u-md-8" >'+
            '<input type="text" name="payInfo[0][payMan]" value="<?php echo @$list['payInfo'][0]['payMan'] ?>" readonly>'+
        '</div>'+
        '</div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
        '<button type="button" class="am-btn am-btn-default">已确认</button></div></div>'+

        '<div class="am-u-md-12 am-form-group">'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额进度款: </label>'+
        '<div class="am-u-md-8">'+
        '<input type="text" name="payInfo[1][prepay]" id="" value="<?php echo @$list['payInfo'][1]['prepay'] ?>" readonly >'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<div class="am-input-group am-u-md-12">'+
        '<input type="text" class="am-form-field" readonly name="payInfo[1][amount]" value="<?php echo @$list['payInfo'][1]['amount'] ?>">'+
        '<span class="am-input-group-label">元</span>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
        '<div class="am-u-md-8">'+
        '<input type="text" name="payInfo[1][payMan]"  id="" value="<?php echo @$list['payInfo'][1]['payMan'] ?>" readonly>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
        '<button type="button" class="am-btn am-btn-default">已确认</button></div></div>'+

                '<div class="am-u-md-12 am-form-group">'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额尾款: </label>'+
        '<div class="am-u-md-8">'+
        '<input type="text" name="payInfo[2][prepay]" id="" value="<?php echo @$list['payInfo'][2]['prepay'] ?>" readonly >'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<div class="am-input-group am-u-md-12">'+
        '<input type="text" class="am-form-field" readonly name="payInfo[2][amount]" value="<?php echo @$list['payInfo'][2]['amount'] ?>">'+
        '<span class="am-input-group-label">元</span>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
        '<div class="am-u-md-8">'+
        '<input type="text" name="payInfo[2][payMan]"  id="" value="<?php echo @$list['payInfo'][2]['payMan'] ?>" readonly>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
        '<button type="button" class="am-btn am-btn-default">已确认</button></div></div>'+

        '<div class="am-u-md-12">'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额质保金: </label>'+
        '<div class="am-u-md-8">'+

        '<select data-am-selected="{btnWidth: \'100%\',maxHeight: 100}" id="payProportion" name="payInfo[3][prepay]">'+
        '<option value="0">请选择付款比例</option>'+
        '<option value="0.05">预付款5%</option>'+
        '<option value="0.1">预付款10%</option>'+
        '<option value="0.15">预付款15%</option>'+
        '<option value="0.2">预付款20%</option>'+
        '<option value="0.3">预付款30%</option>'+
        '<option value="0.4">预付款40%</option>'+
        '<option value="0.5">预付款50%</option>'+
        '<option value="0.6">预付款60%</option>'+
        '<option value="0.7">预付款70%</option>'+
        '<option value="0.8">预付款80%</option>'+
        '<option value="1">预付款100%</option>'+
        '</select></div></div>'+
        '<div class="am-u-md-3">'+
        '<div class="am-input-group am-u-md-12">'+
        '<input type="text" class="am-form-field" id="pay-money" name="payInfo[3][amount]" readonly>'+
        '<span class="am-input-group-label">元</span>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
        '<div class="am-u-md-8">'+
        '<select data-am-selected="{btnWidth: \'100%\',maxHeight: 100}" name="payInfo[3][payMan]" id="payMan">'+
        '<option value="">请选财务人员</option>'+
        '</select></div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
        '<button type="button" class="am-btn am-btn-default">未确认</button></div></div>'
        );

        $(".append").append(
        '<div class="tpl-table-black-operation">'+
        '<a href="javascript:void(0);" class="tpl-table-black-operation-del">'+
        ' 出产抽检报告单'+
        '</a>'+
        '</div>'+
        '<div class="am-u-sm-12">'+
        '<div class="am-g">'+
        '<div class="am-u-sm-12">'+
        '<div class="am-g">'+
        '<div class="am-u-md-6">'+
        '<div class="am-form-group am-u-sm-12">'+
        '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">报告单附件：</label>'+
        reportCardDownload+
        '</div>'+
        '</div>'+
        '</div>'+
        '</div>'+
        '</div>'+
        ' <hr>'+
        '</div>'+
        '<div class="tpl-table-black-operation">'+
        '<a href="javascript:void(0);" class="tpl-table-black-operation-del">'+
        '物流信息验收</a>'+
        '</div>'+
        '<div >'+
        '<div class="am-g">'+
        '<div class="am-u-sm-12">'+
        '<div class="am-g">'+
        '<div class="am-u-md-6">'+
        '<div class="am-form-group am-u-sm-12">'+
        '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">物流公司：</label>'+
        '<div class="am-u-md-10">'+
        '<input type="text" name="express" value="<?php echo @$list['logisticsInfo']['express']?>" id=""  readonly>'+
        '</div>'+
        '</div>'+
        '<div class="am-form-group am-u-sm-12">'+
        '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">物流签收单：</label>'+
        expressCardDownload+
        '</div>'+
        ' </div>'+
        '<div class="am-u-md-6">'+
        '<div class="am-form-group am-u-md-12">'+
        '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">快递单号：</label>'+
        '<div class="am-u-md-10">'+

        '<input type="text" name="courierNumber" value="<?php echo @$list['logisticsInfo']['courierNumber']?>" id="" readonly>'+
        '</div>'+
        '</div>'+
        '<div class="am-form-group am-u-md-12">'+
        '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">终端验收报告：</label>'+
        terminalCardDownload+
        '</div>'+
        '</div></div></div></div><hr></div>'+
        '<div class="tpl-table-black-operation">'+
        '<a href="javascript:void(0);" class="tpl-table-black-operation-del">'+
        '质押金付款单 </a></div>'+
        '<div>'+
        '<div class="am-g">'+
        '<div class="am-u-sm-12">'+
        '<div class="am-u-md-6">'+
        '<div class="am-form-file am-u-sm-12">'+
            '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">验收单附件：</label>'+
            '<div class="am-u-md-10">'+
                '<button type="button" class="am-btn am-btn-default am-btn-sm">'+
                    '<i class="am-icon-cloud-upload"></i> 选择要上传的文件'+
                '</button>'+
                '<input type="file" class="am-u-md-10 form-control" name="pledgeGoldCard" id="pledgeGoldCard">'+
                '<span class="file-show5"></span>'+
            '</div>'+
        '<input type="hidden" name="actionStatus" value="'+status+'">'+
        '</div>'+
        '<span class="am-u-md-10">建议1080*720px</span>'+
        '</div></div></div></div>'
        )

        addAudit("/admin/user/ccLevel","#payMan");//添加审批抄送人

        $("#pledgeGoldCard").change(function (event) {

            var filePath = $(this).val();
            if(filePath){
                var arr = filePath.split('\\');
                var fileName = arr[arr.length-1];
                $(".file-show5").html(fileName);
            }else{
                $(".file-show5").html("");
                return false;
            }
            
        });

    }else if(status == 5){

        $(".pay-message").append('<div class="am-u-md-12 am-form-group">'+
        '<div class="am-u-md-3">'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额预付款: </label>'+
            '<div class="am-u-md-8">'+
                '<input type="text" name="payInfo[0][prepay]"  readonly value="<?php echo @$list['payInfo'][0]['prepay'] ?>">'+
            '</div>'+
        '</div>'+
        '<div class="am-u-md-3">'+
            '<div class="am-input-group am-u-md-12">'+
                '<input type="text" class="am-form-field" name="payInfo[0][amount]" value="<?php echo @$list['payInfo'][0]['amount'] ?>" readonly >'+
                '<span class="am-input-group-label" >元</span>'+
            '</div>'+
        '</div>'+
        '<div class="am-u-md-3" >'+
            '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
            '<div class="am-u-md-8" >'+
            '<input type="text" name="payInfo[0][payMan]" value="<?php echo @$list['payInfo'][0]['payMan'] ?>" readonly>'+
        '</div>'+
        '</div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
        '<button type="button" class="am-btn am-btn-default">已确认</button></div></div>'+

        '<div class="am-u-md-12 am-form-group">'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额进度款: </label>'+
        '<div class="am-u-md-8">'+
        '<input type="text" name="payInfo[1][prepay]" id="" value="<?php echo @$list['payInfo'][1]['prepay'] ?>" readonly >'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<div class="am-input-group am-u-md-12">'+
        '<input type="text" class="am-form-field" readonly name="payInfo[1][amount]" value="<?php echo @$list['payInfo'][1]['amount'] ?>">'+
        '<span class="am-input-group-label">元</span>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
        '<div class="am-u-md-8">'+
        '<input type="text" name="payInfo[1][payMan]"  id="" value="<?php echo @$list['payInfo'][1]['payMan'] ?>" readonly>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
        '<button type="button" class="am-btn am-btn-default">已确认</button></div></div>'+

        '<div class="am-u-md-12 am-form-group">'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额尾款: </label>'+
        '<div class="am-u-md-8">'+
        '<input type="text" name="payInfo[2][prepay]" id="" value="<?php echo @$list['payInfo'][2]['prepay'] ?>" readonly >'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<div class="am-input-group am-u-md-12">'+
        '<input type="text" class="am-form-field" readonly name="payInfo[2][amount]" value="<?php echo @$list['payInfo'][2]['amount'] ?>">'+
        '<span class="am-input-group-label">元</span>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
        '<div class="am-u-md-8">'+
        '<input type="text" name="payInfo[2][payMan]"  id="" value="<?php echo @$list['payInfo'][2]['payMan'] ?>" readonly>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
        '<button type="button" class="am-btn am-btn-default">已确认</button></div></div>'+

        '<div class="am-u-md-12 am-form-group">'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">采购金额质保金: </label>'+
        '<div class="am-u-md-8">'+
        '<input type="text" name="payInfo[3][prepay]" id="" value="<?php echo @$list['payInfo'][3]['prepay'] ?>" readonly >'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<div class="am-input-group am-u-md-12">'+
        '<input type="text" class="am-form-field" readonly name="payInfo[3][amount]" value="<?php echo @$list['payInfo'][3]['amount'] ?>">'+
        '<span class="am-input-group-label">元</span>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款人员: </label>'+
        '<div class="am-u-md-8">'+
        '<input type="text" name="payInfo[3][payMan]"  id="" value="<?php echo @$list['payInfo'][3]['payMan'] ?>" readonly>'+
        '</div></div>'+
        '<div class="am-u-md-3">'+
        '<label class="am-u-md-4 am-md-text-right am-padding-left-0" for="">付款确状态: </label>'+
        '<button type="button" class="am-btn am-btn-default">已确认</button></div></div>'
        );
        
        $(".append").append(
        '<div class="tpl-table-black-operation am-form-group">'+
        '<a href="javascript:void(0);" class="tpl-table-black-operation-del"></fieldset>'+
        ' 出产抽检报告单'+
        '</a>'+
        '</div>'+
        '<div >'+
        '<div class="am-g">'+
        '<div class="am-u-sm-12">'+
        '<div class="am-g">'+
        '<div class="am-u-md-6">'+
        '<div class="am-form-group am-u-sm-12">'+
        '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">报告单附件：</label>'+
        reportCardDownload+
        '</div>'+
        '</div>'+
        '</div>'+
        '</div>'+
        '</div>'+
        ' <hr>'+
        '</div>'+
        '<div class="tpl-table-black-operation am-form-group">'+
        '<a href="javascript:void(0);" class="tpl-table-black-operation-del">'+
        '物流信息验收</a>'+
        '</div>'+
        '<div >'+
        '<div class="am-g">'+
        '<div class="am-u-sm-12">'+
        '<div class="am-g">'+
        '<div class="am-u-md-6">'+
        '<div class="am-form-group am-u-sm-12">'+
        '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">物流公司：</label>'+
        '<div class="am-u-md-10">'+
        '<input type="text" name="express" value="<?php echo @$list['logisticsInfo']['express']?>" id=""  readonly>'+
        '</div>'+
        '</div>'+
        '<div class="am-form-group am-u-sm-12">'+
        '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">物流签收单：</label>'+
        expressCardDownload+
        '</div>'+
        ' </div>'+
        '<div class="am-u-md-6">'+
        '<div class="am-form-group am-u-sm-12">'+
        '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">快递单号：</label>'+
        '<div class="am-u-md-10">'+

        '<input type="text" name="courierNumber" value="<?php echo @$list['logisticsInfo']['courierNumber']?>" id="" readonly>'+
        '</div>'+
        '</div>'+
        '<div class="am-form-group am-u-sm-12">'+
        '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">终端验收报告：</label>'+
        terminalCardDownload+
        '</div>'+
        '</div></div></div></div></div>'+
        '<div class="tpl-table-black-operation am-form-group">'+
        '<a href="javascript:void(0);" class="tpl-table-black-operation-del">'+
        '质押金付款单 </a></div>'+
        '<div >'+
        '<div class="am-g">'+
        '<div class="am-u-sm-12">'+
        '<div class="am-g">'+
        '<div class="am-u-md-6">'+
        '<div class="am-form-group">'+
        '<div class="am-g">'+
        '<label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">验收单附件：</label>'+
        pledgeGoldCardDownload+
        '<input type="hidden" name="actionStatus" value="'+status+'">'+
        '</div></div>'+
        '</div></div></div></div></div>'
        );
    }



    $("#payProportion").change(function(){
        var payProportionNo = $("#payProportion").val();
        var allMoney = $("#all-money").val();
        var payMoney = allMoney*payProportionNo;
        payMoney = payMoney.toFixed(2);
        $("#pay-money").val(payMoney);
    });

    $(function(){
        


        calcPriceAndNum();
        requestSpecification();


        //点击选择商品
        $("#chooseCommodity").click(function(){
            initCategory();
            levelClick(0,0,1);
        });
        
        //点击查询 商品按钮
        $("#searchCommodity").on("click",function(){
            var search = $("#searchValue").val();
            if(!search){
                alert("请输入商品名称查询。");
                return false;
            }
            levelClick(0,0,1,search);
        });

        //点击确认
        var max = 0;
        var lineorder = $("#goodsMessage").find(".order");
        var maxorder = 0;
        for(var i = 0;i < lineorder.length; i++){
            maxorder = lineorder.eq(i).html() == "" ? 0 : parseInt(lineorder.eq(i).html());
            max = Math.max(max,maxorder);
        }

        $("#addCommodity").click(function(){
            var whichCheck = $(".check-one:checked");
            var tr='';
            for(var i = 0;i < whichCheck.length; i++){
                var priceAll = '';
                var product_no = whichCheck.eq(i).parent().siblings(".product_no").text();
                var name = whichCheck.eq(i).parent().siblings(".name").text();
                var goodsUnit = whichCheck.eq(i).parent().siblings(".goodsUnit").text();
                var dataId = whichCheck.eq(i).data("id");
                var ckId = whichCheck.eq(i).data("ckid");
                var stockpriceid = whichCheck.eq(i).data("stockpriceid");
                var classNum;    //类数量
                var hasSpecification = whichCheck.eq(i).data("has");  //是否有规格  1：有  0：无
                max++;
                classNum = max;
                if(max < 10){
                    max = "0" + max;
                }
                tr += '<tr class="line"><td class="order">'+ max +'</td>'
                +'<td data-id="'+ dataId +'" data-ckid="'+ ckId +'" class="product_no">'+ product_no +'</td>'
                +'<td class="name">'+ name +'</td>';
                if(hasSpecification == 1){
                    tr += '<td class="specification"><button type="button" class="am-btn am-btn-default am-radius specification-btn" data-am-modal="{target: \'#addSpecification\', closeViaDimmer: 0, width: 500, height: 400}">商品规格+</button></td>'
                        + '<td class="goodsUnit">'+ goodsUnit +'</td>'
                        +'<td><div class="am-form"><input type="text" name="" class="am-u-md-12 form-control quantity" readonly></div></td>'
                        +'<td><div class="am-form"><input type="text" name="" class="am-u-md-12 form-control price" readonly></div></td>'
                        +'<td class="price-all">'+ priceAll +'</td>'
                        +'<td><div class="am-form"><input type="text" name="" class="am-u-md-12 form-control remarks"></div></td>'
                        + '<td><button type="button" class="am-btn am-btn-danger am-btn-xs delect-btn">删除</button></td>'
                        +'</tr>';
                }else{
                    tr += '<td class="specification" data-id="'+ stockpriceid +'"></td>'
                        + '<td class="goodsUnit">'+ goodsUnit +'</td>'
                        +'<td><div class="am-form"><input type="text" name="" class="am-u-md-12 form-control quantity"></div></td>'
                        +'<td><div class="am-form"><input type="text" name="" class="am-u-md-12 form-control price"></div></td>'
                        +'<td class="price-all">'+ priceAll +'</td>'
                        +'<td><div class="am-form"><input type="text" name="" class="am-u-md-12 form-control remarks"></div></td>'
                        + '<td><button type="button" class="am-btn am-btn-danger am-btn-xs delect-btn">删除</button></td>'
                        +'</tr>';
                }
                
            }
            $("#goodsMessage").append(tr);
            $("#class").text(classNum);  //多少类商品


            //请求规格
            requestSpecification();
            calcPriceAndNum();
        });

        //全选反选
        $("#changeCommodity .check-all").click(function(){
                $("#changeCommodity .check-one").prop("checked",this.checked);
        });
        
    });


    function requestSpecification() {
            $(".specification-btn").unbind("click").click(function(){
                var thisTr = $(this).parents(".line");                   //点击的本行tr
                var productId = thisTr.find(".product_no").data("id");   //传给后台的商品ID
                var ckId = thisTr.find(".product_no").data("ckid");   //传给后台的商品ID
                var product_no = thisTr.find(".product_no").text();   //商品编码
                var name = thisTr.find(".name").text();               //名字
                var goodsUnit = thisTr.find(".goodsUnit").text();     //单位
                var specificationData;                                  //请求规格传给后台的ID
                specificationData = ckId ? ckId : productId;
                $.ajax({    
                    url:"/api/goods/getGoodsByStock",
                    data:{
                        productId:specificationData
                    },
                    dataType:"json",
                    type:"post",
                    async:false,
                    success:function(data){
                        var specificationBox = $(".specification-box");
                        var tr='';
                        for(var i = 0; i < data.length; i++){
                            var specificationId = data[i].id;
                            var specificationArray = data[i].stock.join();
                            tr += '<tr data-id="'+ specificationId +'">'
                                  + '<td class="specification-value">'+ specificationArray +'</td>'
                                  + '<td>'
                                    + '<div class="am-form">'
                                        + '<input type="text" name="" class="">'
                                    + '</div>'
                                  + '</td>'
                                + '</tr>';
                        }
                        specificationBox.html(tr);
                    },
                    error:function(data){
                        console.log(data);
                    }
                });

                // 点击确定添加新规格商品
                $("#confirmSpecification").unbind("click").click(function(){
                    var stockInput = $(".specification-box").find("input");
                    var specificationTr = '';
                    var oneGoodsNum = 0;

                    for(var i = 0;i < stockInput.length; i++){
                        if(stockInput.eq(i).val() == 0 || stockInput.eq(i).val().replace(/(^\s*)|(\s*$)/g, "")==""){
                            continue;
                        }
                        var stockInputVal = stockInput.eq(i).val();  //进货数量
                        var specificationVal = stockInput.eq(i).parents("tr").find(".specification-value").text(); //规格
                        var stockPriceId = stockInput.eq(i).parents("tr").data("id");
                        specificationTr += '<tr class="line">'
                                            + '<td class="orde  r"></td><td class="product_no" data-id="'+ productId +'">'+ product_no +'</td>'
                                            + '<td class="name">'+ name +'</td>'
                                            + '<td class="specification" data-id="'+ stockPriceId +'">'+ specificationVal +'</td>'
                                            + '<td class="goodsUnit">'+ goodsUnit +'</td>'
                                            + '<td><div class="am-form"><input type="text" name="" value="'+ stockInputVal +'" class="am-u-md-12 form-control quantity"></div></td>'
                                            + '<td><div class="am-form"><input type="text" name="" class="am-u-md-12 form-control price"></div></td>'
                                            + '<td class="price-all"></td>'
                                            + '<td><div class="am-form"><input type="text" name="" class="am-u-md-12 form-control remarks"></div></td>'
                                            + '<td><button type="button" class="am-btn am-btn-danger am-btn-xs delect-btn">删除</button></td>'
                                            +'</tr>';
                        
                    }

                    thisTr.after(specificationTr);

                    for(var k = 0 ; k < $("#goodsMessage").find(".quantity").length; k++){
                        var quantityInp = $("#goodsMessage").find(".quantity").eq(k).val();
                        quantityInp = quantityInp == "" ? 0 : quantityInp;
                        oneGoodsNum += parseInt(quantityInp);
                    }
                    $("#quantity-all").text(oneGoodsNum);

                    calcPriceAndNum();
                });

            });
        }

</script>
</body>

</html>